﻿using UnityEngine;

public class VRPlayerTestMono:MonoBehaviour
{
    private Transform _head;
    private Transform _leftArm;
    private Transform _rightArm;
    private Transform _leftLeg;
    private Transform _rightLeg;

    public GameObject bulletPrefab;
    private bool _isShotting = false;
    private float _shotSpeed = 0;


    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log("GetKeyDownAAAAAAAAAAAAAAAAAAAAAAAA");
            _isShotting = true;
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            Debug.Log("GetKeyDownBBBBBBBBBBBBBBBBBBBBBBBB");
            _isShotting = false;
            _shotSpeed = 0;
        }

        if (_isShotting)
        {
            _shotSpeed -= Time.deltaTime;
            if (_shotSpeed <= 0)
            {
                _shotSpeed = 0.5f;

                float angleDetal = 360 / 10;
                for (int i = 0; i < 10; i++)
                {
                    GameObject bullet = Object.Instantiate(bulletPrefab);
                    bullet.transform.position = transform.position;
                    bullet.transform.forward = Quaternion.Euler(0, 0, angleDetal * i) * transform.right;
                    bullet.GetComponent<Rigidbody>().AddForce(bullet.transform.forward.normalized * 500);
                    Object.Destroy(bullet, 3);
                }
            }
        }
    }
}